<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/webjars/layui/2.5.7/css/layui.css"/>
</head>
<script src="/webjars/layui/2.5.7/layui.js"></script>
<script>
    layui.use(['jquery','layer'],function(){
        var layer = layui.layer;
        var $ = layui.jquery;
        $('#tijiao').click(function(){
            //val() 获取输入框里面的值



           $.ajax({
               url:'/user/addUser',
               method:'post',
               data:{username:$('#username').val(),
               sex:$('#sex').val()},
               success:function(data){
                   if(data==1){
                       layer.msg('插入成功')
                   }else{
                       layer.msg('插入失败')
                   }

               },error:function(){
                   layer.msg("与服务器的交互失败")
               }
           })
        })

    })

</script>
<body>
<div>

  用户名  <input id="username" type="text" >
</div>
<div>
 性别  <input id="sex" type="text" >
</div>


<button id="tijiao">提交</button>
</body>
</html>